package com.tools.generator.enums;

import cn.hutool.core.util.StrUtil;

/**
 * DB 枚举
 * @author Admin
 */
public enum dbEnum {

    /**
     * mysql
     */
    MySQL("com.mysql.cj.jdbc.Driver"),

    /**
     * Oracle
     */
    Oracle("oracle.jdbc.driver.OracleDriver"),

    /**
     * SQLServer
     */
    SQLServer("com.microsoft.sqlserver.jdbc.SQLServerDriver"),

    /**
     * PostGreSQL
     */
    PostGreSQL("org.postgresql.Driver"),

    /**
     * SQLite 默认数据源
     */
    SQLite("org.sqlite.JDBC"),


    Clickhouse("com.clickhouse.jdbc.ClickHouseDriver"),

    /**
     * 人大金仓
     */
    KingBase("com.kingbase8.Driver"),
    ;

    private final String driverClass;


    dbEnum(String driverClass) {
        this.driverClass = driverClass;
    }

    public String getDriverClass() {
        return driverClass;
    }

    /**
     *
     * @param dbType 数据库类型
     * @return dbEnum
     */
    public static dbEnum getValue(String dbType) {
        // todo 优化下方魔法值
        if (StrUtil.equalsAny(dbType, "MySQL")) {
            return MySQL;
        }

        if (StrUtil.equalsAny(dbType, "Oracle")) {
            return Oracle;
        }

        if (StrUtil.equalsAny(dbType, "PostgreSQL")) {
            return PostGreSQL;
        }

        if (StrUtil.equalsAny(dbType, "SQLServer", "Microsoft SQL Server")) {
            return SQLServer;
        }

        if (StrUtil.equalsAny(dbType, "SQLite")) {
            return SQLite;
        }

        return null;
    }
}
